<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Black学习社-登录</title>
	<link rel="stylesheet" type="text/css" href="/static/css/reset2.css">
	<link rel="stylesheet" type="text/css" href="/static/css/main.css">
	<script type="text/javascript" src="/static/js/jquery.min.js"></script>
</head>

<body>
	<div class="header_con">
		<div class="header1">
			<div class="welcome fl">欢迎来到Black学习社!</div>
			<div class="fr">
				<div class="login_btn fl">
					<a href="login.html">登录</a>
					<span class="sp">|</span>
					<a href="register.html">注册</a>
				</div>
				<div class="user_link fl">
					<span class="sp">|</span>
					<a href="user_center_order.html">忘记密码</a>
				</div>
			</div>
		</div>		
    </div>
	<div class="login_top clearfix">

		<a href="index.html" class="login_logo"><img src="/static/images/logo.jpg" style="width: 160px; height: 120px;margin-top:0;"></a>

	</div>

	<div class="login_form_bg">
		<div class="login_form_wrap clearfix">
			<div class="login_banner fl"></div>
			<div class="slogan fl"></div>
			<div class="login_form fr">
				<p class="error">{{errmsg}}</P>
				<div class="login_title clearfix"style="margin-top:0">
					<h1>用户登录</h1>
					<a href="register">立即注册</a>
				</div>
				<div class="form_input">
					<div>
						{% csrf_token %}
						<input type="text" id="yhm" name="username" class="name_input" placeholder="请输入用户名">
						<div class="user_error">输入错误</div>
						<input type="password" id="pwd" name="pwd" class="pass_input" placeholder="请输入密码">
						<div class="pwd_error">输入错误</div>
						<div class="more_input clearfix">
							<input type="checkbox" name="">
							<label>记住用户名</label>
							<a href="#">忘记密码</a>
						</div>
						<input type="submit"  value="登录" class="input_submit">
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="footer no-mp">
		<p>CopyRight © jj林 All Rights Reserved</p>
		<p>粤ICP备*******8号</p>
	</div>
	<script>
		$(document).ready(function(){
		 	$('.input_submit').click(function () {
            // 获取用户名和密码
                var schoolid=$('#yhm').val();
				var pwd=$('#pwd').val();
				if(schoolid==''){
					alert("用户名不能为空！");
					return false;
				}
				if(pwd==''){
					alert("密码不能为空！");
					return false;
				}
				else{
					 var params = {
						'username': schoolid,
						'pwd': pwd,
						'csrfmiddlewaretoken': '{{ csrf_token  }}',
					}
					$.post('http:127.0.0.1:8080/user/login', params, function (data) {
						if (data.res == 0){
							alert("登录成功");
							window.location.href ="http://127.0.0.1:8080/";
						}
						else
						{
							alert("登录失败，用户名或密码错误！");

						}
					});
				}
			});

		});


	</script>
</body>
</html>